var getFile = function(s) {
  return 'WEB-INF/template/ftl/demo/' + s + '/index.ftl';
};

module.exports = {
  // mock 请求
  "get /collectList1": function(req, res) {
    res.send({
      result: 'success',
      messages: [],
      fieldErrors: {},
      errors: [],
      data: {
        totalCount: 6,
        pageSize: 3,
        pageIndex: 0,
        listData: [{
          "level": 1,
          "id": 1,
          "name": "一级分类1",
          "datetime": "2014-4-2",
          "isParent": true
        }, {
          "level": 1,
          "id": 2,
          "name": "一级分类2",
          "isParent": true,
          "datetime": "2014-4-2"
        }, {
          "level": 1,
          "id": 3,
          "name": "一级分类3",
          "isParent": true,
          "datetime": "2014-4-2"
        }, {
          "level": 1,
          "id": 4,
          "name": "一级分类4",
          "isParent": true,
          "datetime": "2014-4-2"
        }, {
          "level": 1,
          "id": 5,
          "name": "一级分类5",
          "isParent": true,
          "datetime": "2014-4-2"
        }, {
          "level": 1,
          "id": 6,
          "name": "一级分类6",
          "isParent": true,
          "datetime": "2014-4-2"
        }]
      }
    });
  },

  "get /collectList": function(req, res) {
    var name = req.body.name;
    var pid = req.body.pId;
    var data = {
      totalCount: 10,
      pageSize: 10,
      listData: []
    };
    for(var i = 1;i < 10;i++) {
      /*if (pid && i == 10) {
        break;
      }*/


      if (i > 10 ) {
        data.listData.push({
          level: 2,
          id: i,
          pId: 1,
          name: '子分类' + i,
          isParent: false,
          datetime: '2014-2-2'
        });
      } else {
        data.listData.push({
          level: pid ? 2 : 1,
          id: pid ? pid.toString() + i : i,
          pId: pid ? pid : 0,
          name: pid ? ('子分类' + i) : ('父分类' + i),
          isParent: i !== 1 ? false : true,
          datetime: '2014-2-2'
        });
      }

    }


    res.send({
      result: 'success',
      messages: [],
      fieldErrors: {},
      errors: [],
      data: data
    });
  },

};